package com.itheima.mall.web.ums;

import com.itheima.mall.pojo.ums.UmsMenu;
import com.itheima.mall.service.ums.UmsMenuService;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("menu")
public class UmsMenuController {

    @Autowired
    UmsMenuService umsMenuService;

    @PostMapping("create")
    public R UmsMenuCreate(@RequestBody UmsMenu umsMenu){
        return umsMenuService.UmsMenuCreate(umsMenu);
    }

    @PostMapping("delete")
    public R UmsMenuDelete(Long id){
        return umsMenuService.UmsMenuDelete(id);
    }

    @GetMapping("list/{parentId}")
    public R UmsMenuList(@PathVariable Long parentId, Integer pageNum, Integer pageSize){
        return umsMenuService.UmsMenuList(parentId,pageNum,pageSize);
    }

    @GetMapping("treeList")
    public R UmsMenuTreeList(){
        return umsMenuService.UmsMenuTreeList();
    }

    @PostMapping("update/{id}")
    public R UmsMenuUpdate(@PathVariable Long id, @RequestBody UmsMenu umsMenu){
        return umsMenuService.UmsMenuUpdate(id,umsMenu);
    }

    @PostMapping("updateHidden/{id}")
    public R UmsMenuUpdateHidden(@PathVariable Long id, @RequestParam Integer hidden){
        return umsMenuService.UmsMenuUpdateHidden(id,hidden);
    }

    @GetMapping("{id}")
    public R UmsMenuFindById(@PathVariable Long id){
        return umsMenuService.UmsMenuFindById(id);
    }

}
